//
// Created by user on 2022/1/14.
//
#include <iostream>
#include <vector>
using namespace std;

bool validMountainArray(vector<int>& arr) {

    int n = arr.size();
    if(n<=1){
        return false;
    }
    int i = 1;
    bool flag = false;
    while (i<n && arr[i]>arr[i-1]){
        i++;
        flag = true;
    }
    if(i==n){return false;}

    while (i<n && arr[i]< arr[i-1]){
        i++;
    }
    return i==n && flag;
}

bool validMountainArray1(vector<int>& arr) {
    int n = arr.size();
    if(n<=1){
        return false;
    }
    int i = 0;
    while (i< n-1 && arr[i]<arr[i+1]){i++;}
    if(i==0 || i==n-1){return false;}

    while (i<n-1 && arr[i+1]< arr[i]){i++;}

    return i==n-1;

}

